#include<iostream>
#include<string.h>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
int t;
long long n,a[123456],sum;
int main()
{

    for(long long i=1;i<=100000;i++){
        a[i]=i*(3*i+1)/2;
    }
   // cout<<a[100000];
    cin>>t;

    while(t--){
            sum=0;
        cin>>n;
        while(n){
            if(n<=2){
            if(n==2) sum++;
            break;
            }
            int pos=lower_bound(a,a+100000,n)-(a);
            if(n==a[pos]){
                sum++;
                break;
            }
            //cout<<pos<<endl;
            pos--;
            n-=a[pos];
            sum++;
        }


        cout<<sum<<endl;
    }
    return 0;
}
